<% title_tag t(".Profile") %>

<div class="flex-wrap">
<div class="aside-wrap">
  <%= render "/users/sidebar" %>
</div>
<div class="main-wrap">
  <div class="main-content">
    <h1 class="title"><%= t(".Profile") %></h1>
    <h2 class="sub-title"><%= t(".Avatar") %></h2>
    <%= form_for(@user, url: account_settings_path, html: { method: :put, class: "mb-section" }) do |f| %>
      <input type="hidden" name="_by" value="profile" />
      <div class="avatar-wrap">
        <div class="image-box">
          <%= user_avatar_tag(current_user, style: :large, link: false) %>
        </div>
        <div class="form-group flex-auto">
          <p class="description text-gray">
            <%= t(".This photo will be used to identify you in BlueDoc It will be visible to anyone") %>
            <br>
            <%= t(".Use a photo or image rather than text and upload an image that is 200px square or larger") %>
          </p>
          <label class="btn-upload icon-middle-wrap link-gray-dark">
            <%= icon_tag("text-image") %>
            <%= t(".Upload new picture") %>
            <%= f.file_field :avatar, class: "js-manual-file-chooser" %>
          </label>
        </div>
      </div>
      <script type="text/javascript">
        $("form").on("change", ".js-manual-file-chooser", (e) => {
          $form = $(e.delegateTarget);
          $form.submit();
        });
      </script>
    <% end %>

    <%= form_for(@user, url: account_settings_path, html: { method: :put }) do |f| %>
      <input type="hidden" name="_by" value="profile" />

      <%= form_group(f, :name) do %>
        <%= f.text_field :name, class: "form-control"%>
      <% end %>

      <%= form_group(f, :email) do %>
        <%= f.email_field :email, class: "form-control" %>

        <% if Setting.user_email_limit_enable? %>
        <div class="form-text user-email-suffix-support-list">
          <%= t(".Supported email suffix with list_html", emails: Setting.user_email_suffixes.join(", ")) %>
        </div>
        <% end %>

        <% if @user.unconfirmed_email %>
        <div class="form-text unconfirmed-info">
          <%= t(".Unconfirmed email_html", email: @user.unconfirmed_email) %>
        </div>
        <% end %>
      <% end %>

      <%= form_group(f, :description) do %>
        <%= f.text_field :description, class: "form-control"%>
      <% end %>

      <%= form_group(f, :location) do %>
        <%= f.text_field :location, class: "form-control" %>
      <% end %>

      <%= form_group(f, :url) do %>
        <%= f.url_field :url, class: "form-control" %>
      <% end %>

      <%= form_group(f, :locale, class: "form-group mb-button") do %>
        <%= f.select :locale, Setting.locale_options,
          { include_blank: t(".System default", locale_name: Setting.default_locale_name) },
          { class: "form-control" } %>
      <% end %>

      <div class="form-group">
        <%= f.submit t(".Update profile"), class: "btn btn-primary btn-submit" %>
      </div>
    <% end %>
  </div>
</div>
</div>
